<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\channel as channelmodel;
return new class extends Migration {
    //组织机构
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('channel', function (Blueprint $table) {
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->id();
            $table->string('channelid', 50);
            $table->string('name', 200);
            $table->string('shortname', 200)->nullable();
            $table->string('chinaladdress', 200)->nullable();
            $table->string('engaddress', 200)->nullable();
            $table->string('playtaxid', 200)->nullable();
            $table->integer('isvirtual')->nullable();
            $table->integer('isuse')->nullable();
            $table->bigInteger('treeid');
            $table->bigInteger('parentid')->nullable();
            $table->string('des', 200)->nullable();
            $table->string('des1', 200)->nullable();
            $table->string('des3', 200)->nullable();
            $table->string('tabnm', 50)->nullable();
            $table->string('modifier', 50)->nullable();
            $table->integer('isdel')->nullable()->default(0);
            $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
            $table->timestamp('created_at')->nullable();
        });
        // 插入默认数据
        channelmodel::create([
            'channelid' => '000',
            'name' => '集团总部',
            'treeid' => 1,
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('channel');
    }
};
